package cn.itcast.nems.studentrecord.dao.mapper;

import cn.itcast.nems.studentrecord.dao.dataobject.JournalRenewalAmountDO;
import cn.itcast.nems.studentrecord.dao.dataobject.JournalRenewalDO;
import cn.itcast.nems.studentrecord.dao.entity.JournalRenewal;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface JournalRenewalMapper extends BaseMapper<JournalRenewal> {

    /**
     * 根据 班级ID、校区ID、学科ID、授课模式查询 升级凭单
     * @param clazzId 班级ID
     * @param schoolId 校区ID
     * @param subjectId 学科ID
     * @param modelId 授课模式枚举值
     * @return 升级凭单头
     */
    @Select("select * from e2_journal_renewal where target_clazz_id=#{clazzId} and target_clazz_campus_id= #{schoolId} " +
            "and target_clazz_subject_id=#{subjectId} and target_clazz_model_id=#{modelId}")
    List<JournalRenewal> findListByParams(@Param("clazzId") Integer clazzId ,
                                                                  @Param("schoolId") String schoolId ,
                                                                  @Param("subjectId") String subjectId ,
                                                                  @Param("modelId") String modelId ) ;

    /**
     * 升级凭单分页查询
     * @param page 分页参数
     * @param param 参选参数
     * @return 分页数据
     */
    IPage<JournalRenewalDO> findPageList(Page<JournalRenewalDO> page , @Param("param") JournalRenewalDO param) ;

    /**
     *
     * @param page
     * @param param
     * @return
     */
    IPage<JournalRenewalDO> findClazzPageList(Page<JournalRenewalDO> page , @Param("param") JournalRenewalDO param) ;

    /**
     * 根据凭单ID查询 优惠合计、执行价格
     * @param amountDO
     * @return
     */
    JournalRenewalAmountDO findRenewalAmountById (@Param("amountDO") JournalRenewalAmountDO amountDO) ;


}
